<?php
/**
 * 邀请
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019-03-28
 * Time: 下午 4:39
 */
namespace Model;
class InviteMod extends Mod
{
	public function __construct()
	{
		$this->_table = 'kuyuan_vbz_activity_invite';
	}


    /**
     * 通用用户的uid返回该用户的好友列表
     * @param $_uid  用户id
     * @param $_activity_id 活动id
     * @param $_limit 请求下标
     * @return array 返回好友列表
     */
	public function uidToFriendList($_uid,$_activity_id,$_limit = array(0,10))
    {
        $_sql = "SELECT
                    id,share_uid,invite_uid,open_count
                 FROM
                    ".tablename($this->_table)."
                 WHERE
                    activity_id = :activity_id
                 AND
                    (share_uid =:uid
                 OR
                    invite_uid =:uid)
                 ORDER BY
                    id DESC
                 LIMIT
                    {$_limit[0]},{$_limit[1]}
                ";
        return pdo_fetchall($_sql,array('uid'=>$_uid,'activity_id'=>$_activity_id));
    }

    /**
     * 通用用户的uid返回该用户的好友列表
     * @param $_uid  用户id
     * @param $_activity_id 活动id
     * @return array 返回好友列表
     */
    public function uidToFriendTotal($_uid,$_activity_id)
    {
        $_sql = "SELECT
                    COUNT(`id`)
                 FROM
                    ".tablename($this->_table)."
                 WHERE
                    activity_id = :activity_id
                 AND
                    (share_uid =:uid
                 OR
                    invite_uid =:uid)
                ";
        return pdo_fetchcolumn($_sql,array("uid"=>$_uid,"activity_id"=>$_activity_id));
    }

}